<project-header class="top-header"></project-header>
<project-page>

  <!-- Middle section -->
  <div class="middle-section">
    <div id="scrollable-content" class="middle-container has-scroll">
      <div class="middle-header header-light">
        <div class="container-fluid">
          <div class="page-header page-header-bleed-right page-header-bleed-left">
            <div class="actions pull-right">
              <a ng-href="project/{{project.metadata.name}}/create-route" class="btn btn-default">{{'CreateRoute' | translate}}</a>
            </div>
            <h1>{{'Routes' | translate}}</h1>
          </div>
          <alerts alerts="alerts"></alerts>
          <div ng-if="!renderOptions.showGetStarted" class="row data-toolbar">
            <div class="col-sm-7">
              <project-filter></project-filter>
            </div>
          </div>
        </div>
      </div><!-- /middle-header-->
      <div class="middle-content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-md-12 gutter-top">
              <table class="table table-bordered table-hover table-mobile">
                <thead>
                  <tr>
                    <th>{{'Name' | translate}}</th>
                    <th>{{'Hostname' | translate}}</th>
                    <th>{{'RoutesTo' | translate}}</th>
                    <th>{{'TargetPort' | translate}}</th>
                    <th>{{'TLSTermination' | translate}}</th>
                  </tr>
                </thead>
                <tbody ng-if="(routes | hashSize) == 0">
                  <tr><td colspan="6"><em>{{emptyMessage}}</em></td></tr>
                </tbody>
                <tbody ng-repeat="route in routes | orderObjectsByDate : true">
                  <tr>
                    <td data-title="Name">
                      <a href="{{route | navigateResourceURL}}">{{route.metadata.name}}</a>
                      <route-warnings ng-if="route.spec.to.kind !== 'Service' || services"
                                      route="route"
                                      service="services[route.spec.to.name]">
                      </route-warnings>
                    </td>
                    <td data-title="Hostname">
                      <div ng-if="(route | isWebRoute)" class="word-break">
                        <a href="{{route | routeWebURL}}" target="_blank">{{route | routeLabel}}</a>
                      </div>
                      <div ng-if="!(route | isWebRoute)" class="word-break">
                        {{route | routeLabel}}
                      </div>
                    </td>
                    <td data-title="Routes To">
                      <span ng-if="route.spec.to.kind !== 'Service'">{{route.spec.to.kind}}: {{route.spec.to.name}}</span>
                      <span ng-if="route.spec.to.kind === 'Service'"><a ng-href="{{route.spec.to.name | navigateResourceURL : 'Service': route.metadata.namespace}}">{{route.spec.to.name}}</a></span>
                    </td>
                    <!-- Add non-breaking space to empty cells. Otherwise, table-mobile layout is broken. -->
                    <td data-title="Target Port">
                      <span ng-if="route.spec.port.targetPort">
                        <span ng-if="route.spec.to.kind !== 'Service'">{{route.spec.port.targetPort}}</span>
                        <!-- Show the short display port in the table, but the long in the title attr. -->
                        <span ng-if="route.spec.to.kind === 'Service'"
                              ng-attr-title="{{route | routeTargetPortMapping : services[route.spec.to.name]}}">
                          {{route.spec.port.targetPort}}
                        </span>
                      </span>
                      <span ng-if="!route.spec.port.targetPort">&nbsp;</span>
                    </td>
                    <!-- Use shorter Termination title for table-mobile to avoid overlapping text. -->
                    <td data-title="Termination">
                      {{route.spec.tls.termination}}
                      <span ng-if="!route.spec.tls.termination">&nbsp;</span>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div><!-- /col-* -->
          </div>
        </div>
      </div><!-- /middle-content -->
    </div><!-- /middle-container -->
  </div><!-- /middle-section -->
</project-page>
